//
// File: server.cpp
// Description:
//


#include <iostream>
#include <string>
#include <map>

using namespace std;

#include "network.h"
#include "database.h"
#include "clientmanager.h"

int main(int argc, char **argv) {
	
	map<NetworkPeer, Client> clients;
	
	
	Network & net = Network::run();
	if (net.error() != Network::NO_ERROR) {
		cerr << "Failed to start network";
		exit(1);
	}
	
	ClientManager cm;
	
	
	// Server loop
	for (;;) {
		
		// Check for events
		NetworkEvent e;
		while (net.pollEvent(e)) {
			switch (e.type) {
				case NetworkEvent::CONNECT: {
					cm.add(e.peer);
					break;
				}
				
				case NetworkEvent::DATA: {
					
					break;
				}
				
				case NetworkEvent::DISCONNECT: {
					cm.drop(e.peer);
					break;
				}
			}
		}
		
		
	}
	
	
}
